package com.kxmall.web.controller.huishouapp;

import cn.dev33.satoken.annotation.SaIgnore;
import com.kxmall.common.core.controller.BaseAppController;
import com.kxmall.common.core.domain.PageQuery;
import com.kxmall.common.core.domain.R;
import com.kxmall.common.core.page.TableDataInfo;
import com.kxmall.huishou.domain.bo.HsWasteNewsBo;
import com.kxmall.huishou.domain.vo.HsWasteNewsVo;
import com.kxmall.huishou.domain.vo.HsWasteSiteVo;
import com.kxmall.huishou.service.IHsWasteNewsService;
import com.kxmall.huishou.service.IHsWasteSiteService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 环保科普
 *
 * @author lf
 * @date 2023-12-01
 */

@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/news/app")
public class HsAppNewsController extends BaseAppController {

    private final IHsWasteNewsService iHsWasteNewsService;

    /**
     * APP查询环保科普信息列表
     */
    @GetMapping("/appList")
    public TableDataInfo<HsWasteNewsVo> appList(HsWasteNewsBo bo, PageQuery pageQuery) {
        if(pageQuery != null){
            pageQuery.setIsAsc("desc");
            pageQuery.setOrderByColumn("create_time");
        }
        return iHsWasteNewsService.queryPageList(bo, pageQuery);
    }


    /**
     * APP获取环保科普信息详细信息
     *
     * @param id 主键
     */
    @GetMapping("/{id}")
    public R<HsWasteNewsVo> getAppInfo(@NotNull(message = "主键不能为空")@PathVariable Long id) {
        return R.ok(iHsWasteNewsService.queryById(id));
    }










}
